package adapters;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public abstract class Adapter{
	protected static XFireProxyFactory xFireProxyfactory 
		= new XFireProxyFactory(XFireFactory.newInstance().getXFire());
	
	public abstract String callWebService(String xmlString) throws ParserConfigurationException, SAXException, IOException ;
	
	protected NodeList getParamNodeList(String xmlString) throws ParserConfigurationException, SAXException, IOException, UnsupportedEncodingException {
		DocumentBuilderFactory documentFactory=DocumentBuilderFactory.newInstance();
		DocumentBuilder builder;
		builder = documentFactory.newDocumentBuilder();
		Document doc = builder.parse(new ByteArrayInputStream(xmlString.getBytes("utf8")));
		NodeList paramNodeList = doc.getElementsByTagName("param");
		return paramNodeList;
	}
 
}
